$(function(){
	var wH=$(window).height();
	var bannerH=wH-$(".notice").height();
	$(".banner").css("height",bannerH);
	
	//顶部
	$(window).scroll(function(){
		if($(window).scrollTop()>30){
			$(".navbar").addClass("active");
		}else{
			$(".navbar").removeClass("active");
		}
	});
	
	//中间区域切换
	$(".step-title ul li").click(function(){
		var a =$(this).index();
		if(a===1){
			$(".conflict .text").addClass("animated slideInDown")
			$(".conflict .charts").addClass("animated slideInUp")
		}
		if(a===2){
			$(".compensation .pull-left").addClass("animated slideInLeft")
			$(".compensation .pull-right").addClass("animated slideInRight")
		}
		if(a===3){
			$(".fault .box").addClass("animated slideInLeft");
			$(".fault .text").addClass("animated slideInRight");
		}
		$(".step-title ul li").eq(a).addClass("on").siblings().removeClass("on");
		$(".step-content .con").eq(a).removeClass("hidden").siblings().addClass("hidden");
	})
	
	//加动画
	var offsettopstop=$(".difficult").offset().top;
	var patternsstop=$(".patterns").offset().top;
	var costtop=$(".cost").offset().top;
	$(window).scroll(function(){
		if($(window).scrollTop()+wH > offsettopstop+220){
			$(".difficult .text").animate({"opacity":"1","left":"0"},500);
			$(".difficult .pull-right dl").eq(0).animate({"opacity":"1","right":"0"},500);
			$(".difficult .pull-right dl").eq(1).delay(500).animate({"opacity":"1","right":"0"},500);
			$(".difficult .pull-right dl").eq(2).delay(1000).animate({"opacity":"1","right":"0"},500);
		};
		if($(window).scrollTop()+wH > patternsstop+220){
			$(".patterns ul li").each(function(){
				var time=$(this).data("delay");
				$(this).delay(time).animate({"opacity":"1","width":"20%"},500);
			})
		};
		if($(window).scrollTop()+wH > costtop+150){
			$(".cost dl").each(function(){
				var time=$(this).data("delay");
				$(this).find("dd").delay(time).animate({"opacity":"1","bottom":"0"},500);
			})
		};
		return false;
	})
	
	
	
	
	//返回顶部
	$(".back_top1").click(function(){
		$("body").animate({scrollTop: '0px'}, 800);
	});
	
	//转圈
	window.setInterval("run()", 20)
})

	var dt = 0.4; //弧度0.5,大概30°
	var dt2 = 0.5;
	var dt3 = 1;
	function run() {
	var r = 65;
	var Py = Math.sin(dt) * r +60;
	var Px = Math.cos(dt) * r+62;
	$(".square1 dt i").css({ "left": Px + "px", "top": Py + "px" })
	var Py2 = Math.sin(dt2) * r +60;
	var Px2 = Math.cos(dt2) * r+62;
	$(".square2 dt i").css({ "left": Px2 + "px", "top": Py2 + "px" })
	var Py3 = Math.sin(dt3) * r +60;
	var Px3 = Math.cos(dt3) * r+62;
	$(".square3 dt i").css({ "left": Px3 + "px", "top": Py3 + "px" })
	dt += 0.01;
	dt2 += 0.01;
	dt3 += 0.01;
	}